package com.financing.wap.weixin.handle;

import java.util.Date;
import java.util.Map;

import org.springframework.stereotype.Service;

import com.financing.wap.weixin.resp.TextMessage;
import com.financing.wap.weixin.util.MessageUtil;

/**
 * 默认回复内容
 * @author lisu
 *
 */
@Service("defaultHandler")
public class DefaultHandler implements MessageHandler{

	@Override
	public String messageHandler(Map<String, String> requestMap) {
		// 接收用户发送的文本消息内容  
        String content = requestMap.get("Content");  
        // 发送方帐号（open_id）  
        String fromUserName = requestMap.get("FromUserName");  
        // 公众帐号  
        String toUserName = requestMap.get("ToUserName");  

        TextMessage textMessage = new TextMessage();  
        textMessage.setToUserName(fromUserName);  
        textMessage.setFromUserName(toUserName);  
        textMessage.setCreateTime(new Date().getTime());  
        textMessage.setMsgType(MessageUtil.RESP_MESSAGE_TYPE_TEXT);  
        textMessage.setFuncFlag(0);  
        // 由于href属性值必须用双引号引起，这与字符串本身的双引号冲突，所以要转义  
        textMessage.setContent("您好，我们已经收到您的回复了，请期待我们的服务哦~~");  
        // 将文本消息对象转换成xml字符串  
        return MessageUtil.textMessageToXml(textMessage);
        
        /*// 创建图文消息  
        NewsMessage newsMessagec = new NewsMessage();  
        newsMessagec.setToUserName(fromUserName);  
        newsMessagec.setFromUserName(toUserName);  
        newsMessagec.setCreateTime(new Date().getTime());  
        newsMessagec.setMsgType(MessageUtil.RESP_MESSAGE_TYPE_NEWS);  
        newsMessagec.setFuncFlag(0);  

        List<Article> articleListc = new ArrayList<Article>();  
        Article article1_1 = new Article();  
        article1_1.setTitle("超级理财师最具竞争力产品推荐\n华澳-长昊30号汉江雅苑");  
        article1_1.setDescription("");  
        article1_1.setPicUrl("http://static.superfa.cn/upload/product/file/20141115/1416044184782%E5%8D%8E%E6%BE%B3-%E9%95%BF%E6%98%8A30%E5%8F%B7%E6%B1%89%E6%B1%9F%E9%9B%85%E8%8B%91(1).png");  
        article1_1.setUrl("http://www.superfa.cn/product/12c03926-6811-11e4-b7ce-00163e0e2df9");  

        Article article2_2 = new Article();  
        article2_2.setTitle("中泰信托-沪惠1号");  
        article2_2.setDescription("");  
        article2_2.setPicUrl("http://static.superfa.cn/upload/product/file/20141110/1415607505219%E4%B8%AD%E6%B3%B0%E4%BF%A1%E6%89%98-%E6%B2%AA%E6%83%A01%E5%8F%B7.jpg?1");  
        article2_2.setUrl("http://www.superfa.cn/product/a8fbd0c6-67f3-11e4-b7ce-00163e0e2df9");  

        Article article3_3 = new Article();  
        article3_3.setTitle("财通资产-福通1号");  
        article3_3.setDescription("");  
        article3_3.setPicUrl("http://static.superfa.cn/upload/product/tj1.jpg?1");  
        article3_3.setUrl("http://www.superfa.cn/product/a8fbd0c6-67f3-11e4-b7ce-00163e0e2df9");  

        articleListc.add(article1_1);  
        articleListc.add(article2_2);  
        articleListc.add(article3_3);  
        newsMessagec.setArticleCount(articleListc.size());  
        newsMessagec.setArticles(articleListc);  
        respMessage = MessageUtil.newsMessageToXml(newsMessagec);  */
	}

	@Override
	public void messageSubsequentHandler(Map<String, String> requestMap) {
		// TODO Auto-generated method stub
		
	}


}
